###########################################################
# OS type
###########################################################
win32 {
    contains(QMAKE_COMPILER, 'msvc') {
        CYG_OS = msvc
    } else {
        CYG_OS = mingw
    }
}

unix:CYG_OS    = linux
macx:CYG_OS    = mac

###########################################################
# ARCH type
###########################################################
contains(QT_ARCH, i386) {
    CYG_ARCH   = x32
} else {
    CYG_ARCH   = x64
}

###########################################################
# BUILD type
###########################################################
CYG_TYPE = release
!debug_and_release|build_pass {
    CONFIG(debug, debug|release) {
        CYG_TYPE = debug
        DEBUG_POSTFIX = "d"
    }else {
        CYG_TYPE = release
        DEBUG_POSTFIX = ""
    }
}

###########################################################
# PATH config
###########################################################
CYG_CPP_ROOT       = $${PWD}/../..
CYG_PLT_PATH       = $${CYG_OS}/$${CYG_ARCH}/$${CYG_TYPE}

CYG_INC_PATH       = $${CYG_CPP_ROOT}/include/cyg/pub
CYG_LIB_PATH       = $${CYG_CPP_ROOT}/shadow/$${CYG_PLT_PATH}/lib/cyg/pub
CYG_BIN_PATH       = $${CYG_CPP_ROOT}/shadow/$${CYG_PLT_PATH}/bin

3RD_INC_PATH       = $${CYG_CPP_ROOT}/3rd-party/include
3RD_LIB_PATH       = $${CYG_CPP_ROOT}/3rd-party/shadow/$${CYG_PLT_PATH}/lib
3RD_BIN_PATH       = $${CYG_CPP_ROOT}/3rd-party/shadow/$${CYG_PLT_PATH}/bin

QT_LIB_PATH        = $${CYG_CPP_ROOT}/shadow/$${CYG_PLT_PATH}/lib/qt

CYG_NOPUB_INC_PATH = $${CYG_CPP_ROOT}/include/cyg/nopub
CYG_NOPUB_LIB_PATH = $${CYG_CPP_ROOT}/shadow/$${CYG_PLT_PATH}/lib/cyg/nopub

QT_INC_PATH        = $${CYG_CPP_ROOT}/include/qt

###########################################################
# Default install path
###########################################################
isEmpty(CYG_PREFIX) {
    CYG_PREFIX      = $${CYG_CPP_ROOT}/build/install
}
CYG_INSTALL_PREFIX  = $${CYG_PREFIX}/$${CYG_OS}/$${CYG_ARCH}/p3000$${DEBUG_POSTFIX}
run.path            = $${CYG_INSTALL_PREFIX}/bin
config.path         = $${CYG_INSTALL_PREFIX}/config
script.path         = $${CYG_INSTALL_PREFIX}/script
desktop.path        = $${CYG_INSTALL_PREFIX}/share/applications
icons.path          = $${CYG_INSTALL_PREFIX}/share
res.path            = $${CYG_INSTALL_PREFIX}/res
doc.path            = $${CYG_INSTALL_PREFIX}/doc
other.path          = $${CYG_INSTALL_PREFIX}/other
3rdbin.path         = $${CYG_INSTALL_PREFIX}/3rdbin

###########################################################
# Default include path
###########################################################
INCLUDEPATH        += $${CYG_CPP_ROOT}
INCLUDEPATH        += $${CYG_INC_PATH}
INCLUDEPATH        += $${3RD_INC_PATH}
INCLUDEPATH        += $${3RD_INC_PATH}/log4x
INCLUDEPATH        += $${3RD_INC_PATH}/jsoncpp

###########################################################
# Default compile flags
###########################################################
!equals(CYG_OS, 'msvc') {
    QMAKE_CXXFLAGS += -fpermissive
    QMAKE_CXXFLAGS += -Wno-unused-parameter
    QMAKE_CXXFLAGS += -Wno-deprecated-declarations
} else {
}
DEFINES            += QT_DEPRECATED_WARNINGS

###########################################################
# Default link path
###########################################################
LIBS               += -L$${CYG_LIB_PATH}
LIBS               += -L$${3RD_LIB_PATH}

###########################################################
# Default link flags
###########################################################

unix {
    QMAKE_CXXFLAGS += -fvisibility=hidden
    LIBS           += -Wl,-rpath,../lib/cyg
    LIBS           += -Wl,-rpath,../lib/cyg/plugin
    LIBS           += -Wl,-rpath,../lib/qt/lib
    LIBS           += -Wl,-rpath,../lib/3rd
}

###########################################################
# Replace functions
###########################################################
defineReplace(staticlib_deps) {
    staticlib       = $$1

    equals(CYG_OS, 'msvc') {
        archive     = $$CYG_NOPUB_LIB_PATH/$${staticlib}$${DEBUG_POSTFIX}.lib

    } else {
        archive     = $$CYG_NOPUB_LIB_PATH/lib$${staticlib}$${DEBUG_POSTFIX}.a
    }

    return ($${archive})
}
